#include "types.h"
#include "user.h"
#include "fcntl.h"

int
main(int argc, char *argv[])
{
  if (argc < 2)
  {
      printf(1, "Usage: fileBlocks <filepath>\n");
      exit();
  }
  char* fpath = argv[1];
  uint blocksNumbers[100];
  int nblocks  = fblocks(fpath,blocksNumbers,sizeof(blocksNumbers));
  if (nblocks < 0)
  {
    printf(1,"some error occured\n");
    exit();
  }

  printf(1,"num blocks of file: %d \n",nblocks);
  uint i;
  for (i=0; i<nblocks; ++i)
  {
    int refCount = getrefcount(blocksNumbers[i]);
    printf(1,"%d %d,",blocksNumbers[i], refCount);
  }
  printf(1,"\n");
  exit();
}
